

clear 
set scheme lean2, permanent
global pm = char(177)
set more off

gl date = c(current_date)
if c(os) == "MacOSX" gl user "/Users/`c(username)'"
else if c(os) == "Windows" gl user "C:\Users\\`c(username)'"
else if c(os) == "Unix" gl user "/usr/`c(username)'"
di "$user
 
set graphics on  
 
global path_data_processed "\data\processed"
global path_output "\data\output"
 
clear all
set more off


cd "$path_data_processed"

use "experimentRNall.dta", clear
cd "$path_output"
 
duplicates drop rnid, force

keep emp_hiring rnid

keep if emp_hiring!=.

forvalues i=1/7{
gen emp_hiring`i' = emp_hiring==`i'
}

drop emp_hiring

reshape long emp_hiring, i(rnid) j(type) 

collapse (mean) emp_hiring (sd) sd=emp_hiring (count) n=emp_hiring, by(type)



rename emp_hiring action

gen standarderror = invttail(n-1,0.025)*(sd / sqrt(n))

gen id2=1 if type==1 
replace id2=2 if type==2  
replace id2=3 if type==3  
replace id2=4 if type==4  
replace id2=5 if type==5   
replace id2=6 if type==6 
replace id2=7 if type==7   

    

 set scheme lean2


generate hiz_avg = action + 1*(standarderror)
generate lowz_avg = action - 1*(standarderror)
 
 
gen zero=0
 
   twoway    (rbar action zero id2)   (rcap hiz_avg lowz_avg id2 ),  legend(off) ///
 ylabel(0.2(0.1)0.5) ///
	xlabel( 1 "Strongly disagree" 2 "Disagree" 3 "Somewhat disagree" 4 "Neither agree nor disagree" 5 "Somewhat agree" 6 "Agree" 7 "Strongly agree", noticks labsize(*0.7) angle(45) ) ///	
	xtitle("My employer's hiring depends" "on the aggregate economy.", size(*0.65)) ///
	ytitle("Mean {&plusmn} s.e.m.") ///	  
   xline(1.5 4 6.5 9 11.5 , lwidth(vvthin))  ///
		name(firm_hiring, replace)	
	   graph display firm_hiring, xsize(20) ysize(20)
		graph export "firm_hiring.eps", replace
		graph export "firm_hiring.pdf", replace
		graph save "firm_hiring.gph", replace



cd "$path_data_processed"

use "experimentRNall.dta", clear
cd "$path_output"
 
duplicates drop rnid, force

keep emp_firing rnid

keep if emp_firing!=.

forvalues i=1/7{
gen emp_firing`i' = emp_firing==`i'
}

drop emp_firing

reshape long emp_firing, i(rnid) j(type) 

collapse (mean) emp_firing (sd) sd=emp_firing (count) n=emp_firing, by(type)



rename emp_firing action

gen standarderror = invttail(n-1,0.025)*(sd / sqrt(n))

gen id2=1 if type==1 
replace id2=2 if type==2  
replace id2=3 if type==3  
replace id2=4 if type==4  
replace id2=5 if type==5   
replace id2=6 if type==6 
replace id2=7 if type==7   

    

 set scheme lean2


generate hiz_avg = action + 1*(standarderror)
generate lowz_avg = action - 1*(standarderror)
 
 
gen zero=0
 
   twoway    (rbar action zero id2)   (rcap hiz_avg lowz_avg id2 ),  legend(off) ///
 ylabel(0.2(0.1)0.5) ///
	xlabel( 1 "Strongly disagree" 2 "Disagree" 3 "Somewhat disagree" 4 "Neither agree nor disagree" 5 "Somewhat agree" 6 "Agree" 7 "Strongly agree", noticks labsize(*0.7) angle(45) ) ///	
	xtitle("My employer's firing depends" "on the aggregate economy.", size(*0.65)) ///
	ytitle("Mean {&plusmn} s.e.m.") ///	  
   xline(1.5 4 6.5 9 11.5 , lwidth(vvthin))  ///
		name(firm_firing, replace)	
	   graph display firm_firing, xsize(15) ysize(20)
		graph export "firm_firing.eps", replace
		graph export "firm_firing.pdf", replace
		graph save "firm_firing.gph", replace



cd "$path_data_processed"

use "experimentRNall.dta", clear

cd "$path_output"
 
duplicates drop rnid, force

keep emp_profits rnid

keep if emp_profits!=.

forvalues i=1/7{
gen emp_profits`i' = emp_profits==`i'
}

drop emp_profits

reshape long emp_profits, i(rnid) j(type) 

collapse (mean) emp_profits (sd) sd=emp_profits (count) n=emp_profits, by(type)



rename emp_profits action

gen standarderror = invttail(n-1,0.025)*(sd / sqrt(n))

gen id2=1 if type==1 
replace id2=2 if type==2  
replace id2=3 if type==3  
replace id2=4 if type==4  
replace id2=5 if type==5   
replace id2=6 if type==6 
replace id2=7 if type==7   

    

 set scheme lean2


generate hiz_avg = action + 1*(standarderror)
generate lowz_avg = action - 1*(standarderror)
 
 
gen zero=0
 
   twoway    (rbar action zero id2)   (rcap hiz_avg lowz_avg id2 ),  legend(off) ///
 ylabel(0.2(0.1)0.5) ///
	xlabel( 1 "Strongly disagree" 2 "Disagree" 3 "Somewhat disagree" 4 "Neither agree nor disagree" 5 "Somewhat agree" 6 "Agree" 7 "Strongly agree", noticks labsize(*0.7) angle(45) ) ///	
	xtitle("My employer's profits depend" "on the aggregate economy.", size(*0.65)) ///
	ytitle("Mean {&plusmn} s.e.m.") ///	  
   xline(1.5 4 6.5 9 11.5 , lwidth(vvthin))  ///
		name(firm_profits, replace)	
	   graph display firm_profits, xsize(15) ysize(20)
		graph export "firm_profits.eps", replace
		graph export "firm_profits.pdf", replace
		graph save "firm_profits.gph", replace

 

	
graph combine "firm_firing.gph" "firm_hiring.gph" "firm_profits.gph", xcommon ycommon col(3) iscale(*2) ///
name(insurancefirms, replace)	
	   graph display insurancefirms, xsize(20) ysize(8)
graph export "insurancefirms.pdf", replace


	   
	   
	   

